libxl: events: Deregister evtchn fd when not needed
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 26 Nov 2014 17:27:27 +0000 (17:27 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 10 Dec 2014 13:48:31 +0000 (13:48 +0000)
commit2ffeb5d7f5d8ea35055c6e6642b74078bfc76a73
tree321f0bb4cecfd596aaec8651cf45ef90219e72fb
parent5a9682574538e7cc1b59c17af19ced628ccfe594
libxl: events: Deregister evtchn fd when not needed

We want to have no fd events registered when we are idle.
In this patch, deal with the evtchn fd:

 * Defer setup of the evtchn handle to the first use.
 * Defer registration of the evtchn fd; register as needed on use.
 * When cancelling an evtchn wait, or when wait setup fails, check
   whether there are now no evtchn waits and if so deregister the fd.
 * On libxl teardown, the evtchn fd should therefore be unregistered.
   assert that this is the case.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Ian Campbell <ian.campbell@citrix.com>
Release-Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
v2: Do not bother putting evtchn_fd in the ctx; instead, get it
     from xc_evtchn_fd when we need it.  (Cosmetic.)
    Do not register the evtchn fd multiple times: check it's not
     registered before we call libxl__ev_fd_register.  (Bugfix.)
tools/libxl/libxl.c
tools/libxl/libxl_event.c